import Vue from 'vue'
import Router from 'vue-router'
import Layout from '../layout/index'
Vue.use(Router)
export let constantRouterMap = []
export function getConstantRouterMap() {
  constantRouterMap = [{
      path: '/login',
      meta: {
        title: '登录',
        keepAlive: true
      },
      component: (resolve) => require(['@/views/login'], resolve),
      hidden: true
    },
    {
      path: '/register',
      meta: {
        title: '注册',
        keepAlive: true
      },
      component: (resolve) => require(['@/views/register'], resolve),
      hidden: true
    },
    {
      path: '/retrievepwd',
      meta: {
        title: '找回密码',
        keepAlive: true
      },
      component: (resolve) => require(['@/views/retrievepwd'], resolve),
      hidden: true
    },
    {
      path: '/404',
      component: (resolve) => require(['@/views/features/404'], resolve),
      hidden: true
    },
    {
      path: '/redirect',
      component: Layout,
      hidden: true,
      children: [{
        path: '/redirect/:path*',
        component: (resolve) => require(['@/views/features/redirect'], resolve)
      }]
    },
    {
      path: '/',
      component: Layout,
      redirect: '/index',
      hidden: true,
      children: [{
        path: 'index',
        component: (resolve) => require(['@/views/default/index'], resolve),
        name: 'index',
        meta: {
          title: '首页',
          icon: 'leftmenu-desktop',
          affix: true,
          keepAlive: true
        }
      }, {
        path: 'dashboard',
        component: (resolve) => require(['@/views/home'], resolve),
        name: 'dashboard',
        meta: {
          title: '工作台',
          icon: 'leftmenu-desktop',
          affix: true,
          keepAlive: true
        }
      }, {
        path: 'newfile',
        meta: {
          title: '快捷入口',
          keepAlive: true
        },
        component: (resolve) => require(['@/layout/new_file'], resolve),
        hidden: true
      }, {
        path: 'wuyeContent',
        meta: {
          title: '物业模块',
          keepAlive: true
        },
        component: (resolve) => require(['@/layout/wuye_Content'], resolve),
        hidden: true
      }, {
        path: 'wuyeshoufei',
        meta: {
          title: '物业收费',
          keepAlive: true
        },
        component: (resolve) => require(['@/layout/wuye_shoufei'], resolve),
        hidden: true
      }, {
        path: 'wuyeGongdan',
        meta: {
          title: '物业工单',
          keepAlive: true
        },
        component: (resolve) => require(['@/layout/wuye_Gongdan'], resolve),
        hidden: true
      }, {
        path: 'addgongdan',
        meta: {
          title: '新增工单',
          keepAlive: true
        },
        component: (resolve) => require(['@/layout/add_gongdan'], resolve),
        hidden: true
      }]
    },
    {
      path: '/auth/login',
      meta: {
        title: '授权登录',
        keepAlive: true
      },
      component: (resolve) => require(['@/views/auth/login'], resolve),
      hidden: true
    }
  ]
  return constantRouterMap
}

export default new Router({
  mode: 'history',
  scrollBehavior: () => ({
    y: 0
  }),
  routes: getConstantRouterMap()
})
